//
//  ExtractedFunctionDemo.swift
//  SwiftUIDemo
//
//  Created by Tilt Wang on 2025/6/26.
//

import SwiftUI

struct ExtractedFunctionDemo: View {
    
    @State var backgroundColor: Color = .pink
    
    var body: some View {
        ZStack {
            backgroundColor.ignoresSafeArea(.all)
            
            contentLayer
        }
    }
    
    var contentLayer: some View {
        VStack {
            Text("title")
                .font(.largeTitle)
            
            Button {
                buttonPressed()
            } label: {
                Text("press me")
                    .font(.headline)
                    .foregroundColor(.white)
                    .padding()
                    .background(.black)
                    .cornerRadius(10)
            }

        }
    }
    
    func buttonPressed() {
        backgroundColor = .yellow
    }
}

#Preview {
    ExtractedFunctionDemo()
}
